#include "BulletFactory.h"

CBulletFactory* CBulletFactory::m_BulletFactory = NULL;

CBulletFactory::CBulletFactory()
{
}

CBulletFactory::~CBulletFactory(void)
{
	if(!m_BulletList.empty())
		m_BulletList.clear();
}

CBullet* CBulletFactory::CreateBullet(float speed, int direction, float x, float y)
{
	CBullet* b = NULL;
	if(direction >= DIRECTION_UP && direction <= DIRECTION_LEFT)
	{
		b = new CBullet(CResManager::GetInstance()->m_spriteBullet[direction][0]);
		b->Shoot(speed,direction,x,y);
		m_BulletList.push_back(b);
	}

	return b;
}

CBulletFactory* CBulletFactory::GetFactory()
{
	if(m_BulletFactory == NULL)
		m_BulletFactory = new CBulletFactory();
	return m_BulletFactory;
}

void CBulletFactory::CloseFactory()
{
	if(m_BulletFactory)
		delete m_BulletFactory;
	m_BulletFactory = NULL;
}